package com.egao.appo.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.appo.mapper.IntroductionMapper;
import com.egao.appo.entity.Introduction;
import com.egao.appo.service.IntroductionService;
import org.springframework.stereotype.Service;
import com.egao.appo.biz.IntroductionBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 介绍记录服务实现类
 * @author : Doman
 * @date : 2021-07-23 16:57:31
 * @version ：1.0
 */
@Service
public class IntroductionServiceImpl /*extends ServiceImpl<IntroductionMapper, Introduction> */implements IntroductionService {

	@Autowired
	private IntroductionBiz introductionBiz;

    /**
    @Override
    public PageResult<Introduction> listPage(PageParam<Introduction> page) {
        List<Introduction> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<Introduction> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, Introduction introduction, User loginUser)  throws Exception{
        return introductionBiz.list(page,introduction,loginUser);
    }

    @Override
    public JsonResult list(Introduction introduction, User loginUser) {
        return JsonResult.ok().setData(introductionBiz.list(introduction,loginUser));
    }

    @Override
    public JsonResult getById(Introduction introduction) {
        return JsonResult.ok().setData(introductionBiz.getById(introduction));
    }

    @Transactional
    @Override
    public JsonResult save(Introduction introduction, User loginUser) {
        if (introductionBiz.save(introduction, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(Introduction introduction, User loginUser) {
        if (introductionBiz.update(introduction, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(Introduction introduction, User loginUser) {
        if (introductionBiz.remove(introduction, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
